#include <stdio.h>

int main()
{
    int year,mounth;
    scanf("%d %d",&year,&mounth);

    if((year%4==0 && year%100!=0)||(year%400==0))
        {
            if(mounth==1 || mounth==3 || mounth==5 || mounth==7 || mounth==8 || mounth==10 || mounth==12)
                printf("31");
            else if(mounth=2)
                printf("29");
            else if(mounth==4 || mounth==6 || mounth==9 || mounth==11)
                printf("30");
        }
    else
        {
            if(mounth==1 || mounth==3 || mounth==5 || mounth==7 || mounth==8 || mounth==10 || mounth==12)
                printf("31");
            else if(mounth=2)
                printf("28");
            else if(mounth==4 || mounth==6 || mounth==9 || mounth==11)
                printf("30");
        }

    return 0;
}